#include "../images/ui.h"
#include "ui_helpers.h"
#include "pcf8563.h"
#include "fat.h"
lv_obj_t * ui_restoreFollow;
lv_obj_t * ui_restore_Label1;
lv_obj_t * ui_restoreLabel2;
void restore_event_yesButton1(lv_event_t * e);
lv_obj_t * restore_yesButton1;
void restore_event_noButton1(lv_event_t * e);
lv_obj_t * restore_noButton2;

void restore_event_yesButton1(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
				 //
				 g_system_para.brightness=50;
			   g_system_para.bluetooth_flag=1;
			   adjust_level(g_system_para.brightness);
			   time_dec.year=24;
				 time_dec.moom=1;
			   time_dec.dat=1;
			   time_dec.hour=8;
			   time_dec.min=0;
			   
				 set_time(time_dec);	   
         lv_scr_load_anim(ui_SettingsUnit,LV_SCR_LOAD_ANIM_NONE, 10, 0,true);
    }
}
void restore_event_noButton1(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
         lv_scr_load_anim(ui_SettingsUnit,LV_SCR_LOAD_ANIM_NONE, 10, 0,true);
    }
}
void ui_restore_screen_init(void)
{
    ui_restoreFollow = lv_obj_create(NULL);
    lv_obj_clear_flag(ui_restoreFollow, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_restoreFollow, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_restoreFollow, 255, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_restorePanel = lv_obj_create(ui_restoreFollow);
    lv_obj_set_width(ui_restorePanel, 240);
    lv_obj_set_height(ui_restorePanel, 223);
    lv_obj_set_x(ui_restorePanel, 0);
    lv_obj_set_y(ui_restorePanel, 60);
    lv_obj_clear_flag(ui_restorePanel, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_radius(ui_restorePanel, 20, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_restorePanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_restorePanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_restorePanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_noButton1 = lv_btn_create(ui_restorePanel);
    lv_obj_set_width(ui_noButton1, 100);
    lv_obj_set_height(ui_noButton1, 60);
    lv_obj_set_x(ui_noButton1, -64);
    lv_obj_set_y(ui_noButton1, 60);
    lv_obj_set_align(ui_noButton1, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_noButton1, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_noButton1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_noButton1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_noButton1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_color(ui_noButton1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_opa(ui_noButton1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_width(ui_noButton1, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_pad(ui_noButton1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_yesButton2 = lv_btn_create(ui_restorePanel);
    lv_obj_set_width(ui_yesButton2, 100);
    lv_obj_set_height(ui_yesButton2, 60);
    lv_obj_set_x(ui_yesButton2, 64);
    lv_obj_set_y(ui_yesButton2, 60);
    lv_obj_set_align(ui_yesButton2, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_yesButton2, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_yesButton2, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_yesButton2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_yesButton2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_color(ui_yesButton2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_opa(ui_yesButton2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_width(ui_yesButton2, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_pad(ui_yesButton2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_restoreFollow_Label1 = lv_label_create(ui_restorePanel);
    lv_obj_set_width(ui_restoreFollow_Label1, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_restoreFollow_Label1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_restoreFollow_Label1, 0);
    lv_obj_set_y(ui_restoreFollow_Label1, -30);
    lv_obj_set_align(ui_restoreFollow_Label1, LV_ALIGN_CENTER);
    lv_label_set_text(ui_restoreFollow_Label1, "Factory set?");
    lv_obj_set_style_text_font(ui_restoreFollow_Label1, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_restoreFollow_Label2 = lv_label_create(ui_restoreFollow);
    lv_obj_set_width(ui_restoreFollow_Label2, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_restoreFollow_Label2, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_restoreFollow_Label2, 0);
    lv_obj_set_y(ui_restoreFollow_Label2, 10);
    lv_obj_set_align(ui_restoreFollow_Label2, LV_ALIGN_TOP_MID);
    lv_label_set_text(ui_restoreFollow_Label2, "Factory set");
    lv_obj_set_style_text_color(ui_restoreFollow_Label2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui_restoreFollow_Label2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui_restoreFollow_Label2, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_yesLabel3 = lv_label_create(ui_restoreFollow);
    lv_obj_set_width(ui_yesLabel3, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_yesLabel3, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_yesLabel3, 63);
    lv_obj_set_y(ui_yesLabel3, 90);
    lv_obj_set_align(ui_yesLabel3, LV_ALIGN_CENTER);
    lv_label_set_text(ui_yesLabel3, "Yes");

    lv_obj_t *ui_yesLabel4 = lv_label_create(ui_restoreFollow);
    lv_obj_set_width(ui_yesLabel4, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_yesLabel4, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_yesLabel4, -63);
    lv_obj_set_y(ui_yesLabel4, 90);
    lv_obj_set_align(ui_yesLabel4, LV_ALIGN_CENTER);
    lv_label_set_text(ui_yesLabel4, "No");

    lv_obj_add_event_cb(ui_yesButton2, restore_event_yesButton1, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_noButton1, restore_event_noButton1, LV_EVENT_ALL, NULL);

}
void restore_caller(lv_event_t *e)
{
    ui_restore_screen_init();
    lv_disp_load_scr(ui_restoreFollow);
}